﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DateFormatDemo
{
    public partial class Form1 : Form
    {

        private readonly DateTimeFormatInfo _dtFormat;
        public Form1()
        {
            _dtFormat = new DateTimeFormatInfo {LongDatePattern = "yyyy/MM/dd hh:mm:ss"};
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var date = Convert.ToDateTime(textBox1.Text, _dtFormat);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
